# -*- coding: utf-8 -*-
# @Time    : 2022/7/18 9:29
# @Author  : haichuan
# @Email   : 2263126410@163.com
# @File    : xtbs_zzjg_xgbumpage.py
# @Software: PyCharm
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import  sleep
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.select import Select
from pages.denglu_page import Deng_BasePage


class Xgbum(Deng_BasePage):
    '''修改部门页面类'''
    url="http://localhost/crm"
    # 定义定位器
    '''进入组织架构'''
    user_Heads = (By.CSS_SELECTOR ,'li.dropdown:nth-child(6) > a:nth-child(1)')
    zzjg_xlk = (By.CSS_SELECTOR ,'li.dropdown:nth-child(6) > ul:nth-child(2) > li:nth-child(4) > a:nth-child(1)')
    zzjg__jgzz = (By.CSS_SELECTOR ,'.page-header > h4:nth-child(1) > small:nth-child(1) > a:nth-child(1)')

    '''组织架构-安全维护部门的岗位-安全维护经理。鼠标悬浮、修改'''
    gangwei = (By.XPATH ,'//*[@id="browser"]/li/ul/li[5]/ul/li[1]/span')
    gangwei_xgai = (By.XPATH ,'/html/body/div[5]/div[2]/form/div[2]/ul/li/ul/li[5]/ul/li[1]/span/span/a[1]')

    '''部门提示框修改'''
    gangwei_name = (By.XPATH ,'//*[@id="name"]')
    # name_gangwei = '安全经理'
    suoshubumen = (By.ID ,'department_id')
    shangjigangwei = (By.ID ,'parent_id')
    gangweitext = (By.ID ,'description')
    # gangweitext_txt = '强大的网络安全部'
    queding = (By.XPATH ,'/html/body/div[10]/div[3]/div/button[1]/span')


    def access_zzjg(self):
        action = ActionChains( self.driver )
        '''点击头像，点击组织架构，跳转组织架构界面点击 第二个组织架构标题，'''
        self.driver.find_element(*self.user_Heads ).click()
        sleep(1)
        self.driver.find_element(*self.zzjg_xlk ).click()
        sleep(0.5)
        self.driver.find_element(*self.zzjg__jgzz ).click()

    def suspend_bum(self):
        action = ActionChains(self.driver)
        '''选择安全维护部'''
        gangwei_btn=self.driver.find_element(*self.gangwei)
        sleep(2)
        action.move_to_element( gangwei_btn ).perform()
        sleep(1)
        '''鼠标悬浮在安全岗位，点击修改'''
        gangwei_btn_btnxg = self.driver.find_element( *self.gangwei_xgai )
        action.move_to_element( gangwei_btn_btnxg ).perform()
        self.driver.find_element( *self.gangwei_xgai ).click()
        sleep( 2 )

    def alter_bumname(self,bum_name):
        '''部门名'''
        self.driver.find_element( *self.gangwei_name ).clear()
        self.driver.find_element( *self.gangwei_name ).send_keys(bum_name)
    def select(self):
        '''所属部门，上级部门'''
        locator = self.driver.find_element( *self.suoshubumen )
        select_bumen = Select( locator )
        select_bumen.select_by_index( 5 )

        locator_gangwei = self.driver.find_element( *self.shangjigangwei )
        select_gangwei = Select( locator_gangwei )
        select_gangwei.select_by_index( 1 )

    def description(self,descriptiontest):
        '''部门描述'''
        self.driver.find_element( *self.gangweitext ).clear()
        self.driver.find_element( *self.gangweitext ).send_keys(descriptiontest)
    def confirm(self):
        '''部门描述'''
        self.driver.find_element( *self.queding ).click()






'''提示框中修改'''







